﻿using System;
using Microsoft.Practices.Unity.InterceptionExtension;
using Sapit.Attributes.Interfaces;

namespace Sapit.Unity.Attributes
{
        /// <summary>
        /// Apply this attribute to methods that should be cached.
        /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public class CacheAttribute : HandlerAttribute, ICache
    {
        /// <summary>
        /// Number of seconds to cache the result of the method
        /// </summary>
        public int CacheSeconds { get; set; }

        public override ICallHandler CreateHandler(Microsoft.Practices.Unity.IUnityContainer container)
        {
            return new CacheHandler<object>();
        }
    }
}
